package com.testing.sqlUtil;

import java.sql.SQLException;
import java.util.Map;

/**
 * @Classname MysqlUtilsTest
 * @Description 类型说明
 * @Date 2021/1/8 20:29
 * @Created by 勾勾
 */
public class MysqlUtilsTest {
    public static void main1(String[] args){
        MysqlUtils GG=new MysqlUtils();
        GG.createConnector();
        System.out.println(GG.getUserInfo("roy"));
    }


    public static void main(String[] args) {
        MysqlUtils GG=new MysqlUtils();
        GG.createConnector();


        //调用getUserInfo()方法 获取到{nickname=roy, id=52, describe=哈哈, pwd=123456, username=roy}
        Map<String, String> userInfoMap = GG.getUserInfo("roy");
        String jsonResult="{";
        //遍历map所有的键
        for (String key : userInfoMap.keySet()) {
            //密码和用户名不返回
            if(!key.equals("pwd")&&!key.equals("username")){
                jsonResult+="\""+key+"\":\""+userInfoMap.get(key)+"\",";
            }
        }
        jsonResult+="}";
        jsonResult=jsonResult.replaceAll(",}","}");
        System.out.println(jsonResult);

    }

}
